(function (a) {
    a.fn.extend({

        tabify: function (b) {
            function c(b) {
                return hash = a(b).find("a").attr("href"),
                hash = hash.substring(0, hash.length - 4)
            }
            function d(b) {
                a(b).addClass("active"),
                a(c(b)).show(), a(b).siblings("li").each(function () {
                    a(this).removeClass("active"),
                    a(c(this)).hide()
                })
            }
            return this.each(function () {
                function g() {
                    location.hash && a(h).find("a[href=" + location.hash + "]").length > 0 && d(a(h).find("a[href=" + location.hash + "]").parent())
                }
                var h = this,
                    i = {
                        ul: a(h)
                    };
                a(this).find("li a").each(function () {
                    a(this).attr("href", a(this).attr("href") + "-tab")
                }), location.hash && g(), setInterval(g, 100),
                a(this).find("li").each(function () {
                    a(this).hasClass("active") ? a(c(this)).show() : a(c(this)).hide()
                }),
                b && b(i)
            })
        }
    })
})(jQuery);


